Skip to content

[AutoComplete] use sublime text like search instead of Levenshtein Distance for fuzzy search#4164

Merged
oliviertassinari merged 1 commit intomui:masterfrom
ddeath:fix-autocomplete-filters
May 6, 2016
Merged

[AutoComplete] use sublime text like search instead of Levenshtein Distance for fuzzy search#4164
oliviertassinari merged 1 commit intomui:masterfrom
ddeath:fix-autocomplete-filters

Conversation

@ddeath
Copy link
Copy Markdown
Contributor

@ddeath ddeath commented May 5, 2016

The problem was that fuzzy search used Levenshtein Distance for matching.
It resulted that Peach was not matched by ea.

So i use search similar to the sublime text fuzzy search in ctrl + p also inspired by https://github.com/mattyork/fuzzy

Basically pattern will match if you will get it from search text by deleting some letters.

If someone would like Levenshtein Distance there is still filter for them.

@ddeath
Copy link
Copy Markdown
Contributor Author

ddeath commented May 5, 2016

This is for issue #4159

Comment thread src/AutoComplete/AutoComplete.spec.js Outdated

describe('<AutoComplete />', () => {
it('search using fuzzy filter', () => {
assert.ok(AutoComplete.fuzzyFilter('ea', 'Peach'), 'should match Peach with ea');
Copy link
Copy Markdown
Member

@oliviertassinari oliviertassinari May 5, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rather use this pattern instead of ok/notOk.

assert.strictEqual(actual, true, 'reason');
assert.strictEqual(actual, false, 'reason');

@oliviertassinari
Copy link
Copy Markdown
Member

@ddeath The logic looks good to me. Thanks for adding some tests! Could you have a look at my comments?

@ddeath
Copy link
Copy Markdown
Contributor Author

ddeath commented May 5, 2016

@oliviertassinari I already did 😄

@oliviertassinari
Copy link
Copy Markdown
Member

@ddeath Awesome.
Could you squash down the commits and use this PR name in the commit message?

@ddeath ddeath force-pushed the fix-autocomplete-filters branch from aa2addc to 6fbf19a Compare May 5, 2016 09:42
@ddeath
Copy link
Copy Markdown
Contributor Author

ddeath commented May 5, 2016

@oliviertassinari done

@nathanmarks
Copy link
Copy Markdown
Contributor

@ddeath can you add a couple more tests (with slightly longer and more complex strings)? A a couple of "close but no cigar" non-matches would be good too 👍 Would be cool to have the limitations documented.

@ddeath ddeath force-pushed the fix-autocomplete-filters branch from 6fbf19a to c0cb49c Compare May 5, 2016 13:44
@ddeath
Copy link
Copy Markdown
Contributor Author

ddeath commented May 5, 2016

@nathanmarks

Hi I added some more test, but I could not came up with anything else, since it appears to be quite simple algorithm...

If you have any ideas feel free to share it with me I can write some more tests then.

@nathanmarks
Copy link
Copy Markdown
Contributor

@ddeath great, thanks!

@nathanmarks nathanmarks added this to the 0.15.1 Release milestone May 5, 2016
@oliviertassinari oliviertassinari merged commit 2f78136 into mui:master May 6, 2016
@oliviertassinari
Copy link
Copy Markdown
Member

@ddeath Thanks!

@zannager zannager added the scope: autocomplete Changes related to the autocomplete. This includes ComboBox. label Mar 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: autocomplete Changes related to the autocomplete. This includes ComboBox.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants